package ace.module.weixin.sdk.core.api;

import ace.cmp.core.model.R;
import ace.module.weixin.api.WxsMiniAppApi;
import ace.module.weixin.api.model.dto.WxsGetPhoneNumberResultDto;
import ace.module.weixin.api.model.dto.WxsJsCode2SessionResultDto;
import ace.module.weixin.sdk.core.constant.SdkConstant;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author Caspar 微信服务-小程序 api
 */
@FeignClient(
    value =
        "${spring.cloud.openfeign.client.wxsMiniAppFeign.name:" + SdkConstant.FEIGN_SERVICE_NAME
            + "}",
    contextId = "wxsMiniAppFeign",
    path = WxsMiniAppFeign.PATH)
public interface WxsMiniAppFeign extends WxsMiniAppApi {

  String PATH = "${spring.cloud.openfeign.client.wxsMiniAppFeign.path:/weixin/mini/app}";

  @GetMapping("/getOpenIdByLoginCode")
  R<WxsJsCode2SessionResultDto> getOpenIdByLoginCode(
      @NotEmpty @RequestParam("appId") String appId,
      @NotEmpty @RequestParam("loginCode") String loginCode);

  @GetMapping("/getPhoneNumberByPhoneNumberCode")
  R<WxsGetPhoneNumberResultDto> getPhoneNumberByPhoneNumberCode(
      @NotEmpty @RequestParam("appId") String appId,
      @NotEmpty @RequestParam("phoneNumberCode") String phoneNumberCode);
}
